<!DOCTYPE html><html lang="zh-CN"><head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>&#x52A0;&#x8F7D;&#x8BED;&#x8A00;&#x73AF;&#x5883; (&#x6D4F;&#x89C8;&#x5668;) | Moment.js &#x6587;&#x6863;</title>
  <link rel="stylesheet" href="static/css/style.css">
  <link rel="shortcut icon" href="http://momentjs.cn/static/img/moment-favicon.png">
  <link rel="stylesheet" href="static/css/atom-one-light.min.css">
</head>
<body class="is-moment">
  <div class="hero hero-oneline">
    <div class="hero-centered">
      <h1>&#x52A0;&#x8F7D;&#x8BED;&#x8A00;&#x73AF;&#x5883; (&#x6D4F;&#x89C8;&#x5668;)</h1>
    </div>
  </div>
  <div id="api-section-__FILENAME__">
    <div id="content" class="clearfix">
  
      <div id="column1" data-id="__ID__" class="interior">
        <header>
          <!-- <h1>加载语言环境 (浏览器)</h1> -->
          <div id="gtoc">
            <ul>
              <!-- <li>v</li> -->
              <li>
                <a href="index.html#/i18n/loading-into-browser/" name="toc">&#x8FD4;&#x56DE;&#x4E0A;&#x5C42;&#x6587;&#x6863;</a>
              </li>
              <li style="border: none;">
                <a href="javascript:window.open('https://github.com/momentjscn/moment-docs-cn/edit/master/moment/06-i18n/04-loading-into-browser.md');" rel="nofollow" target="_blank">&#x63D0;&#x4EA4;&#x4FEE;&#x6539;</a>
              </li>
              <!-- <li>
                <a href="/search__SEARCH_PARAM__" name="toc">搜索</a>
              </li> -->
            </ul>
          </div>
          <hr>
        </header>

        <div id="biz_item"></div>
  
        <div id="apicontent">
          <div id="content_left">
							<div class="docs-method-signature">
								<pre><code class="language-js">// &#x4ECE; 2.8.1 &#x5F00;&#x59CB;
moment.locale(String, Object);

// &#x5E9F;&#x5F03;&#x4E8E; 2.8.1
moment.lang(String, Object);
</code></pre>

							</div>
<p>&#x5728;&#x6D4F;&#x89C8;&#x5668;&#x4E2D;&#x52A0;&#x8F7D;&#x8BED;&#x8A00;&#x73AF;&#x5883;&#x4EC5;&#x9700;&#x8981;&#x5305;&#x62EC;&#x8BED;&#x8A00;&#x73AF;&#x5883;&#x6587;&#x4EF6;&#x3002;
&#x786E;&#x4FDD;&#x6307;&#x5B9A;&#x5B57;&#x7B26;&#x96C6;&#x4EE5;&#x9632;&#x6B62;&#x7F16;&#x7801;&#x95EE;&#x9898;&#x3002;</p>
<pre><code class="language-html">&lt;script src=&quot;moment.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;locale/fr.js&quot; charset=&quot;UTF-8&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;locale/pt.js&quot; charset=&quot;UTF-8&quot;&gt;&lt;/script&gt;
&lt;script&gt;
  moment.locale(&apos;fr&apos;);  // &#x8BBE;&#x7F6E;&#x9ED8;&#x8BA4;/&#x5168;&#x5C40;&#x7684;&#x8BED;&#x8A00;&#x73AF;&#x5883;&#x3002;
  // ...
&lt;/script&gt;
</code></pre>
<p>&#x6709;&#x6240;&#x6709;&#x8BED;&#x8A00;&#x73AF;&#x5883;&#x7684;&#x538B;&#x7F29;&#x7248;&#x672C;&#xFF1A;</p>
<pre><code class="language-html">&lt;script src=&quot;moment.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;min/locales.js&quot; charset=&quot;UTF-8&quot;&gt;&lt;/script&gt;
</code></pre>
<p>&#x4E3A;&#x4E86;&#x6700;&#x5927;&#x7A0B;&#x5EA6;&#x5730;&#x51CF;&#x5C11; HTTP &#x8BF7;&#x6C42;&#xFF0C;&#x8BF7;&#x4F7F;&#x7528; Grunt &#x4EFB;&#x52A1;&#x4EE5;&#x81EA;&#x5B9A;&#x4E49;&#x7684;&#x8BED;&#x8A00;&#x73AF;&#x5883;&#x5217;&#x8868;&#x6765;&#x7F16;&#x8BD1; <a href="javascript:window.open('http://nodejs.cn/s/KWLUqN');" target="_blank" rel="nofollow">Moment</a>&#xFF1A;</p>
<pre><code class="language-bash">grunt transpile:fr,it
</code></pre>
<pre><code class="language-html">&lt;script src=&quot;min/moment-with-locales.custom.js&quot; charset=&quot;UTF-8&quot;&gt;&lt;/script&gt;
</code></pre>
<p>&#x5982;&#x679C;&#x4F7F;&#x7528; JSPM &#x4F5C;&#x4E3A;&#x63D2;&#x4EF6;&#x7BA1;&#x7406;&#x5668;&#xFF0C;&#x5219;&#x5E94;&#x5728; lib &#x4E2D;&#x6DFB;&#x52A0;&#x8BED;&#x8A00;&#x73AF;&#x5883;&#x3002;</p>
<pre><code>import * as moment from &apos;moment&apos;;
import &apos;moment/locale/fr&apos;;
</code></pre>
<p>&#x6CE8;&#x610F;&#xFF1A;&#x8BED;&#x8A00;&#x73AF;&#x5883;&#x6587;&#x4EF6;&#x662F;&#x4EE5; <a href="javascript:window.open('http://nodejs.cn/s/VYAEvd');" target="_blank" rel="nofollow">UMD</a> &#x98CE;&#x683C;&#x5B9A;&#x4E49;&#x7684;&#xFF0C;&#x56E0;&#x6B64;&#x5B83;&#x4EEC;&#x5E94;&#x5728;&#x6240;&#x6709;&#x73AF;&#x5883;&#x4E2D;&#x65E0;&#x7F1D;&#x8FD0;&#x884C;&#x3002;</p>
					</div>
          <div id="content_right">
							<div class="docs-method-signature">
								<pre><code class="language-js">// From 2.8.1 onward
moment.locale(String, Object);

// Deprecated in 2.8.1
moment.lang(String, Object);
</code></pre>

							</div>
<p>Loading locales in the browser just requires you to include the locale files. Be sure to specify the charset to prevent encoding issues.</p>
<pre><code class="language-html">&lt;script src=&quot;moment.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;locale/fr.js&quot; charset=&quot;UTF-8&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;locale/pt.js&quot; charset=&quot;UTF-8&quot;&gt;&lt;/script&gt;
&lt;script&gt;
  moment.locale(&apos;fr&apos;);  // Set the default/global locale
  // ...
&lt;/script&gt;
</code></pre>
<p>There are minified versions of all locales together:</p>
<pre><code class="language-html">&lt;script src=&quot;moment.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;min/locales.js&quot; charset=&quot;UTF-8&quot;&gt;&lt;/script&gt;
</code></pre>
<p>To minimize HTTP requests, use our Grunt task to compile <a href="javascript:window.open('https://github.com/moment/moment');" target="_blank" rel="nofollow">Moment</a> with a custom list of locales:</p>
<pre><code class="language-bash">grunt transpile:fr,it
</code></pre>
<pre><code class="language-html">&lt;script src=&quot;min/moment-with-locales.custom.js&quot; charset=&quot;UTF-8&quot;&gt;&lt;/script&gt;
</code></pre>
<p>If you are using JSPM as plugin manager, you should add the locale in your lib.</p>
<pre><code>import * as moment from &apos;moment&apos;;
import &apos;moment/locale/fr&apos;;
</code></pre>
<p><strong>Note:</strong> Locale files are defined in <a href="javascript:window.open('https://github.com/umdjs/umd');" target="_blank" rel="nofollow">UMD</a> style, so they should work seamlessly in all environments.</p>
					</div>
          <div></div>
        </div>
      </div>
    </div>
  </div>
  
  <script src="static/js/highlight.min.js"></script>
  <script src="static/js/javascript.min.js"></script>
  <script>hljs.initHighlightingOnLoad();</script>
  <script>var _hmt = _hmt || []; (function () { var hm = document.createElement("script"); hm.src = "//hm.baidu.com/hm.js?7a7f78c805fbacc7e075d34f153031aa"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })();</script>

  <style>
    .hero-centered {
      margin: 0;
          margin-left: 10px;
    }
#gtoc ul {
  list-style: none;
  margin-left: 0;
  line-height: 1.5rem;
  padding: 0;
}
#gtoc>ul>li {
  display: inline;
  border-right: 1px solid #000;
  margin-right: .4rem;
  padding-right: .4rem;
}
#gtoc>ul>li>a {
  color: #61b2a7;
}
#content_left {
  width: 49%;float: left;border-right: 1px solid #eee;    padding-right: 2%;
}
#content_right {
float: left;width: 48%;margin-left: 3%;
}
#column1 {
  padding: 0 2rem;
}
  </style>


</body></html>